<SCRIPT type="text/javascript">
	
		var setting = {
			check: {
				enable: true,
				chkStyle: "radio",
				radioType: "all"
			},
			view: {
				dblClickExpand: false
			},
			data: {
				simpleData: {
					enable: true
				}
			},
			callback: {
				onClick: onClick,
				onCheck: onCheck
			}
		};

		var zNodes =[
			{id:0, pId:0, name:"用户分组（/）", open:true, nocheck:true}
			<#if organList??>
			<#list organList as org>
			,{ id:"${org.id!''}", pId:"${org.parentid!''}", name:"${org.name!''}", icon:"/assets/images/icon-file-closed.png", open:true, nocheck:true}
			</#list>
			</#if>
		 ];

		function onClick(e, treeId, treeNode) {
			$("#citySel").val(treeNode.name);
			$("#organid").val(treeNode.id);
			$("#menuContent").css("display","none");
		}

		function onCheck(e, treeId, treeNode) {
			var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
			nodes = zTree.getCheckedNodes(true),
			v = "";
			for (var i=0, l=nodes.length; i<l; i++) {
				v += nodes[i].name + ",";
			}
			if (v.length > 0 ) v = v.substring(0, v.length-1);
			var cityObj = $("#citySel");
			cityObj.attr("value", v);
		}

		function showMenu() {
			var cityObj = $("#citySel");
			var cityOffset = $("#citySel").offset();
			$("#menuContent").css({left:cityOffset.left + "px", top:cityOffset.top + cityObj.outerHeight() + "px"}).slideDown("fast");

			$("body").bind("mousedown", onBodyDown);
		}
		function hideMenu() {
			$("#menuContent").fadeOut("fast");
			$("body").unbind("mousedown", onBodyDown);
		}
		function onBodyDown(event) {
			if (!(event.target.id == "menuBtn" || event.target.id == "citySel" || event.target.id == "menuContent" || $(event.target).parents("#menuContent").length>0)) {
				hideMenu();
			}
		}

		$(document).ready(function(){
			$.fn.zTree.init($("#treeDemo"), setting, zNodes);
		});
	
	</SCRIPT>
<div class="artCon">
	<div class="middleArt">
	<form class="form-horizontal" id="organaddForm" action="/${orgi}/manage/account/organaddo.html" method="post">
		
		<div class="artMain">
			<div class="mainCenter">

					<fieldset class="control-group">
						<label class="control-label" for="name">选择分组：</label>
						<div class="controls">
							<input id="citySel" type="text" class="span3" readonly value="" onclick="showMenu();" />
						</div>
					</fieldset>

				</div>
		</div>
		<div class="mainCenter">
		</div>
		<div class="bottomBg">
			<div class="btnWrap">
				<a href="javascript:submitCopyForm()" class="btnStyle1">确认</a>
				<input type="button" onclick="closeR3ArtDialog()" class="cancelButtonStyle" value="取消"/>
			</div>
		</div>
	</form>
	</div>
</div>
<div id="menuContent" class="menuContent setScroll" style="display:none;width:263px; position: fixed; background:#fff;overflow-x:hidden; border:1px #999; border-style:none solid solid; overflow-y:auto">
	<ul id="treeDemo" class="ztree" style="margin-top:0; width:180px; height: 300px;"></ul>
</div>
<script type="text/javascript">
	$(function(){
		$(".mainCenter ul li").hover(function(){
			$(this).addClass("cur").siblings("li").removeClass("cur");
		},function(){
			$(this).removeClass("cur");	
		});
	})
</script>
